<template>
  <div>
    <h3>送货订单</h3>
    <el-table :data="orderObj" style="width: 100%" border="1">
      <el-table-column prop="id" label="订单号"  />
      <el-table-column prop="consignee" label="收货人" />
      <el-table-column prop="phone" label="收货人电话" />
      <el-table-column prop="totalPrice" label="订单总价" />
      <el-table-column fixed="right" label="结账" width="">
        <template #default="scope">
          <el-button link type="primary" size="small" @click="updateStatus(scope.row)">结账</el-button>
        </template>
      </el-table-column>
    </el-table>
  </div>
</template>

<script>
import axios from "axios";
export default {
  data() {
    return {
      orderObj:{}
    }
  },methods:{
    showAll(){
      axios.get("/project/order/showAll").then(resp=> {
        if(resp.data == "noLogin"){
          console.log(resp.data)
          this.$router.push('/shopLogin')
        }
        this.orderObj = resp.data;
      });
    },updateStatus(orderObj){
      axios.get("/project/order/updateStatus",{params:{orderId:orderObj.id}}).then(resp=> {
        if(resp.data=="ok"){
          alert("完成订单")
          this.showAll();
        }
      });
    }

  },created() {
    this.showAll();
  }
}
</script>

<style scoped>

</style>